package com.balance.anole.erp.report.script;

import net.sf.jasperreports.engine.JRDefaultScriptlet;
import net.sf.jasperreports.engine.JRScriptletException;
import net.sf.jasperreports.renderers.JCommonDrawableRenderer;

import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PiePlot3D;
import org.jfree.data.general.DefaultPieDataset;
import org.jfree.util.Rotation;

public class DemoCharScript extends JRDefaultScriptlet{
	
	public void afterReportInit() throws JRScriptletException {
		DefaultPieDataset dataset = new DefaultPieDataset();
		dataset.setValue("Globe", new Double(12.0));
		dataset.setValue("Territorial Distributor", new Double(32.0));
		dataset.setValue("Sub Distributor", new Double(56.0));

		JFreeChart chart = ChartFactory.createPieChart3D(
				"Agent Role Description",
				dataset,
				true,
				true,
				false
				);

		PiePlot3D plot = (PiePlot3D) chart.getPlot();
		plot.setStartAngle(290);
		plot.setDirection(Rotation.CLOCKWISE);
		plot.setForegroundAlpha(0.5f);
		plot.setNoDataMessage("No data to display");

		/*   */
		this.setVariableValue("DemoChar", new JCommonDrawableRenderer(chart));
	}
}
